package ThreadPool.jike.demo07;



/**
 * @param
 * @author oyz
 * @version 1.1.0
 * @description: 数据竞争测试
 * @date 2022-8-23 13:37
 */
public class DataRaceTest {

    private static long count = 0;

    //private static volatile DataRaceTest dataRaceTest = new DataRaceTest();

     static void  add(){
        int id = 0;
        while (id++<10000){
            count += 1;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        // new两个线程
        Thread t1 = new Thread(()->{
            add();
        });
        Thread t2 = new Thread(()->{
            add();
        });
        t1.start();
        t2.start();
        // 主线程等待
        t2.join();
        t2.join();

        System.out.println(count);
    }


}
